"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
//TODO 门卫扫码的页面       没做
//TODO 一堆接口
var constant_1 = __importDefault(require("./utils/constant"));
var util_1 = require("./utils/util");
// 路由守卫 next() 放行
var routerBeforeEach = function (next) {
    var token = wx.getStorageSync('SYS_TOKEN');
    // TODO 获取用户信息 存储
    if (token) {
        // 登录成功
        next();
        return;
    }
    // 登录失败 的操作
    next();
};
var OldPage = Page;
Page = function (options) {
    var oldLoad = options.onLoad;
    var oldShow = options.onShow;
    options.onLoad = function () {
        var _this = this;
        routerBeforeEach(function () {
            oldLoad === null || oldLoad === void 0 ? void 0 : oldLoad.apply(_this, arguments);
        });
    };
    options.onShow = function () {
        var _this = this;
        routerBeforeEach(function () {
            oldShow === null || oldShow === void 0 ? void 0 : oldShow.apply(_this, arguments);
        });
    };
    OldPage(options);
};
// app.ts
App({
    globalData: {
        navBarHeight: 0,
        menuRight: 0,
        menuTop: 0,
        menuHeight: 0,
    },
    onLaunch: function () {
        // 展示本地存储能力
        var that = this;
        // 获取系统信息
        var systemInfo = wx.getSystemInfoSync();
        // 胶囊按钮位置信息
        var menuButtonInfo = wx.getMenuButtonBoundingClientRect();
        // 导航栏高度 = 状态栏高度 + 44
        that.globalData.navBarHeight = systemInfo.statusBarHeight + 44;
        that.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
        that.globalData.menuTop = menuButtonInfo.top;
        that.globalData.menuHeight = menuButtonInfo.height;
        // 登录
        console.log("app.ts============");
        var userinfo = wx.getStorageSync(constant_1.default.USER_INFO);
        if (!userinfo) {
            util_1.wxLogin();
        }
    },
});
